import React, { Component } from 'react';

let aaa = 0;

class Index extends Component {

  state = {
    list: ['张三', '李四', '王五'],
    data: 1,
  };

  add = () => {
    aaa = aaa + 1;
    console.log('aaa', aaa);
  };

  componentDidMount() {
    this.setState({
      data: this.state.data + 1,
    });
    console.log('aaa-did', aaa);
  }

  componentWillUnmount() {
    console.log('Unmount', aaa);
  }


  render() {
    console.log('aaa', aaa);
    return (
      <div>
        {this.state.list[aaa]}
        <h1>{aaa}</h1>
        <div>
          <button onClick={this.add}>点击添加</button>
        </div>
      </div>
    );
  }
}

export default Index;
